﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using XbsWebAPI.Application;
using XbsWebAPI.Application.Detaileds;
using XbsWebAPI.Application.Detaileds.Dto;
using XbsWebAPI.Application.QueryModel;

namespace XbsWebAPI.MainHost.Controllers
{
    [ApiController]
    [Route("api/xbs_v1/[controller]")]
    public class DetailedController : ControllerBase
    {

        private readonly IDetailedAppService _detailAppServicel;
        public DetailedController(IDetailedAppService detailAppServicel)
        {
            _detailAppServicel = detailAppServicel;
        }

        ///<summary>
        ///新增收入
        /// </summary>
        [HttpPost, Route("[action]")]
        public Task<ResultDto<CreateDetailedDto>> AddDetail(CreateDetailedDto model) {
            
            return _detailAppServicel.AddDetail(model);
        }

        /// <summary>
        /// 分页查询/条件查询
        /// </summary>
        /// <param name="orderNumber">订单编号</param>
        /// <param name="wxName">微信昵称</param>
        /// <param name="pageNumber"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet, Route("[action]")]
        public ResultDto<PageListDto<CreateDetailedDto>> FindDetailedPagedList(string orderNumber, string wxName, int? pageNumber,int? pageSize) {
            var queryDetailed=new QueryDetailed();
            queryDetailed.OrderNumber = orderNumber;
            queryDetailed.WxName = wxName;
            queryDetailed.PageSize = pageSize;
            queryDetailed.PageNumber = pageNumber;
            return _detailAppServicel.FindDetailPagedList(queryDetailed);
        }
    }
}
